import {
    ADD_NUMBER,
    SUB_NUMBER,
    INCREMENT,
    DECREMENT,
    BANNERS,
    SET_USERDATA
  } from './constants.js';

  import axios from "axios"

  
  
  // action 主要是派发事件
  export const addAction = num => ({
    type: ADD_NUMBER,
    num
  });
  
  export const subAction = num => ({
    type: SUB_NUMBER,
    num
  });
  
  export const incAction = () => ({
    type: INCREMENT
  });
  
  export const decAction = () => ({
    type: DECREMENT
  });

  export const getBannersAction = (banners) => ({
    type: BANNERS,
    banners
  });


  // 保存用户信息
  export const setuserdataActions = (userdata) => ({
    type: SET_USERDATA,
    userdata
  });


  // rudux-thunk

  export const getBanners=(dispatch)=>{
  
    axios.get("/http/list").then(res=>{
      // 拿到数据再去触发 对应的actions中的方法 
      dispatch(getBannersAction(res.data))
      
    })
  }


  
  